<template>
  <img src="../../static/bg.png" alt="" class="bg" />
  <div class="topSitting">头部占位</div>
  <div class="userInfoArea">
    <img src="../../static/my_head.png" alt="" class="advantar" />
    <div class="userInfo">
      <div class="userPhone">
        <div class="userName">{{ userInfo.name }}</div>
        <div>{{ userInfo.phone }}</div>
      </div>
      <div>2020/02/02 14:30</div>
    </div>
  </div>
  <div class="mainArea">
    <div class="mainAreaBg"></div>
    <div class="mainItem">
      <div class="leftArea">
        <img src="../../static/performance.png" alt="" class="itemIcon" />
        <div class="itemText">我的业绩</div>
      </div>
      <div class="arrowIcon"></div>
    </div>
    <div class="mainItem" @click="goMyCode">
      <div class="leftArea">
        <img src="../../static/qr code_icon.png" alt="" class="itemIcon" />
        <div class="itemText">我的二维码</div>
      </div>
      <div class="arrowIcon"></div>
    </div>
    <div class="mainItem" @click="updatePhone">
      <div class="leftArea">
        <img src="../../static/change_my.png" alt="" class="itemIcon" />
        <div class="itemText">手机号变更</div>
      </div>
      <div class="arrowIcon"></div>
    </div>
    <div class="mainItem" @click="updatePwd">
      <div class="leftArea">
        <img
          src="../../static/reset_password_icon.png"
          alt=""
          class="itemIcon"
        />
        <div class="itemText">重置密码</div>
      </div>
      <div class="arrowIcon"></div>
    </div>
  </div>
  <div class="outLogin" @click="outLogin">退出登录</div>
</template>

<script setup>
import { ref, reactive, onMounted } from "vue";
import * as http from "../../utils/http";
const userInfo = reactive({
  name: "",
  phone: "",
  loginTime: "",
});
onMounted(() => {
  // 首页个人信息
  http
    .personage({
      id: store.userId,
    })
    .then((res) => {
      userInfo.name = res.data.name;
      userInfo.phone = res.data.phone;
      userInfo.loginTime = res.data.loginTime;
    });
});
// 我的二维码
const goMyCode = () => {
  wx.navigateTo({
    url: "../../packageOrder/myCode/myCode",
  });
};
// 重置密码
const updatePwd = () => {
  wx.navigateTo({
    url: "../../packageLogin/updatePwd/updatePwd",
  });
};
// 手机号变更
const updatePhone = () => {
  wx.navigateTo({
    url: "../../packageLogin/updatePwd/updatePwd",
  });
};
// 退出登录
const outLogin = () => {
  wx.removeStorage({
    key: "token",
    success: () => {
      wx.reLaunch({
        url: "../../packageLogin/login/login",
      });
    },
    fail: () => {
      wx.showToast({
        title: "请重新退出登录",
        mask: "true",
        icon: "none",
        duration: 1000,
      });
    },
  });
};
</script>

<style scoped lang="scss">
.outLogin {
  width: 590rpx;
  height: 88rpx;
  line-height: 88rpx;
  text-align: center;
  border-radius: 44rpx;
  margin: 180rpx 80rpx;
  color: #fff;
  font-size: 32rpx;
  font-weight: 600;
  background-image: linear-gradient(to right, #619df1, #4478c1);
}
.mainArea {
  margin: 30rpx 28rpx;
  padding: 0 40rpx;
  height: 450rpx;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  .mainItem {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .leftArea {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      .itemIcon {
        width: 50rpx;
        height: 50rpx;
        margin-right: 20rpx;
      }
      .itemText {
        font-size: 28rpx;
        color: #333333;
        font-weight: 600;
      }
    }
    .arrowIcon {
      width: 12rpx;
      height: 12rpx;
      border-top: 1rpx solid #999999;
      border-right: 1rpx solid #999999;
      transform: rotate(45deg);
    }
  }
  .mainAreaBg {
    width: 100%;
    height: 100%;
    background-color: #fff;
    opacity: 0.7;
    position: absolute;
    left: 0;
    top: 0;
    z-index: -999;
    border-radius: 16rpx;
  }
}
.userInfoArea {
  margin: 0 30rpx;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .advantar {
    width: 144rpx;
    height: 144rpx;
    margin-right: 20rpx;
  }
  .userInfo {
    font-size: 24rpx;
    color: #666666;
    .userPhone {
      display: flex;
      justify-content: flex-start;
      align-items: center;
      margin-bottom: 10rpx;
      .userName {
        font-size: 36rpx;
        color: #333333;
        font-weight: 600;
        margin-right: 30rpx;
      }
    }
  }
}
.bg {
  width: 750rpx;
  height: 863rpx;
  position: absolute;
  left: 0;
  top: 0;
  z-index: -9999;
}
.topSitting {
  height: 187rpx;
  opacity: 0;
}
</style>
